﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TjZheng.Mvc;
using TjZheng.Framework;

namespace TjZheng.Example.MVC.Controllers
{
    //[BarFilter]
    //[FooFilter("Controller")]
    //[ZooFilter]
    public class CorsController : Controller
    {
        //[FooFilter("Index")]
        public void Index()
        {
            Response.Write("CorsController.Index<br/>");

            var obj = new
            {
                Code = "响应编码",
                Message = "相应消息",
                Data = new
                {
                    UserId = "用户Id",
                    UserName = "用户名称",
                    Avatar = "用户头像"
                }
            };
        }

        public void Test1()
        {
            Response.Write("CorsController.Test1<br/>");
        }
        //[BarFilter]
        public void Test2()
        {
            Response.Write("CorsController.Test2<br/>");
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.HttpContext.Response.Write("CorsController.OnActionExecuting<br/>");
        }

        protected override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            filterContext.HttpContext.Response.Write("CorsController.OnResultExecuted<br/>");
        }

        [FooResultFilter]
        public ActionResult CreateException()
        {
            //"name".CreateSqlParameters("namevalue");
            //throw new Exception("抛异常");
            return Content("Cors.CreateException<br/>");
        }
    }
}
